import { createApp } from "vue";
import App from "./mainApp.vue";
import { pinia as pinia1, useTestStore as useTestStore1, StoreID as StoreID1 } from "#/stores";
import { pinia as pinia2, useTestStore as useTestStore2, StoreID as StoreID2 } from "@sfx/test";
import { getActivePinia } from "pinia";

/**
 * 启动
 * - 定义应用工作空间
 * - 初始化应用偏好设置
 * - 启动应用并挂载主页面
 */
(async function launch() {
    // 定义工作平台
    const suffix = "workspace";
    const version = import.meta.env.VITE_APP_VERSION;
    const workspace = `${import.meta.env.VITE_APP_TITLE}-${version}-${suffix}`;
    console.log(workspace);

    // app
    // await initPreferences({
    //     namespace,
    //     overrides: overridesPreferences,
    // });

    // 启动应用并挂载
    // const { bootstrap } = await import('./common/bootstrap');
    // await bootstrap(workspace);

    // const pinia1 = createPinia();
    // const pinia0 = (await import("#/sotres")).pinia;
    // const pinia2 = (await import("@sfx/test")).pinia;

    const app = createApp(App);
    app.use(pinia1);
    app.use(pinia2);
    // app.use(pinia3);
    app.mount("#app");

    const testStore1 = useTestStore1();
    // testStore1.setToken("app-store")
    console.log(localStorage.getItem(StoreID1.TEST_STORE));

    //
    const testStore2 = useTestStore2();
    // testStore2.setToken("lib-store")
    console.log(localStorage.getItem(StoreID2.TEST_STORE));

    // const testStore3 = useTestStore3();
    // testStore3.setToken("web-store")
    // console.log(localStorage.getItem(StoreID3.TEST_STORE));

    //
    console.log(getActivePinia());

    //
    // 移除并销毁loading
    // unmountGlobalLoading();
    //
})();

async function test() {}
